package cn.abc.def.service;

import cn.abc.def.domain.ResponseResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Resource;

@Service
public class SpringTransactionalServiceImpl {
    @Resource
    private TransactionTemplate transactionTemplate;

    public ResponseResult test() {
        String execute = transactionTemplate.execute(transactionStatus -> {
            //TODO 业务逻辑
//            transactionStatus.setRollbackOnly();  //手动回滚
            return "str";  //返回值，支持泛型
        });
        return new ResponseResult(execute);
    }
}
